package com.joker.service;

import com.joker.dao.UserMapper;
import com.joker.pojo.User;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements UserService{
    private UserMapper userMapper;

    @Override
    public User selectme(Integer userid) {
        return userMapper.selectme(userid);
    }

    @Override
    public int adduser(User user) {
        System.out.println("添加的用户信息"+user);
        return userMapper.adduser(user);
    }

    @Override
    public boolean login(User user) {
        ArrayList<User> restusers =userMapper.login(user);
        System.out.println("输出查到的结果集"+restusers.size());
        if(restusers.size()>0){
            return true;
        }
        else {
            return false;
        }
    }

    @Override
    public boolean CheckIfregister(User user) {
        ArrayList<User> restuser=userMapper.CheckIfregister(user);
        //若存在返回false,不存在返回true
        if(restuser.size()>0){
            return false;
        }
        else {
            return true;
        }
    }

    @Override
    public int updateheadimg(User user) {
        return userMapper.updateheadimg(user);
    }

    @Override
    public int updatemyxinxi(User user) {
        return userMapper.updatemyxinxi(user);
    }

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper=userMapper;
    }
}
